package com.oak.broke.model.vip.v1;


import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.oak.broke.group.Query;
import com.oak.broke.group.Save;
import com.oak.broke.model.vip.service.IVipApplyService;
import com.oak.broke.model.vip.vo.VipApplyVO;
import com.oak.broke.model.vip.base.ResponseMessage;
import com.oak.broke.model.vip.dto.VipApplyDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * vip申请机构
 *
 * @author guoxy
 * @email broke@gmail.com
 * @date 2023-05-18 10:37:20
 */
@Api(value = "会员申请api")
@RestController
@RequestMapping("/api/v1/vip/apply")
@Slf4j
public class VipApplyV1Api {
    @Autowired
    private IVipApplyService vipApplyService;

    @ApiOperation("查询所有会员申请")
    @PostMapping("/list")
    public ResponseMessage<IPage<VipApplyVO>> listVipApply(@Validated(value = {Query.class}) @RequestBody VipApplyDTO dto) {
        return ResponseMessage.success(vipApplyService.listVipApply(dto));
    }

    @ApiOperation("保存会员申请")
    @PostMapping("/save")
    public ResponseMessage save(@Validated(value = {Save.class}) @RequestBody VipApplyDTO dto) {
        log.info("保存会员用户信息，请求参数入参为:{}", JSONUtil.toJsonStr(dto));
        vipApplyService.saveApply(dto);
        return ResponseMessage.success();
    }
}
